<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        body {
            height: 3000px;
        }
    </style>
</head>

<body>
    <script>
        var body = window.body
        window.onscroll = function () {
            var scrollHeight = document.documentElement.scrollHeight
            var clientHeight = document.documentElement.clientHeight
            var scrollTop = document.documentElement.scrollTop
            if (scrollHeight - clientHeight - scrollTop <= 400) {
                console.log(123)
                
                console.log(scrollHeight)
            }
        }
    </script>
</body>

</html>